s = "([])"


var isValid = function(s) {
    let len=s.length
    const stack=[]
    if(len%2!==0)
    {
        return false
    }
    const map=new Map()
    map.set("(",")")
    map.set("[","]")
    map.set("{", "}")
    for(let i=0;i<len;i++)
    {
       if(map.has(s[i]))
       {
             stack.push(s[i])
       }    
       else{
        if(stack.length===0)
        {
            return false
        }
           const a=stack.pop()
           if(map.get(a)!==s[i])
           {
            return false
           } 
       }
    }
    if(stack.length!==0)return false
    return true
    
};
console.log(isValid(s));
